package com.ciwong.epaper.modules.me.ui;

import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ciwong.epaper.R;
import com.ciwong.epaper.modules.me.util.MeJumpManager;
import com.ciwong.epaper.modules.share.QQShareHelper;
import com.ciwong.epaper.util.EConstants;
import com.ciwong.epaper.widget.ShareQRcodeDialog;
import com.ciwong.mobilelib.i.ViewOnClickListener;
import com.ciwong.mobilelib.ui.BaseActivity;
import com.ciwong.mobilelib.utils.BaseJumpManager;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.tencent.connect.common.Constants;

import java.util.Hashtable;

/**
 * 关于界面
 *
 * @author res-qqlin
 * @version ciwong v.2.0 2015/8/10
 * @since ciwong v.2.0
 */
public class AboutActivity extends BaseActivity {
    private Button mTvShare;
    private ImageView mIvAppicon;
    private RelativeLayout about_agreement_shiyong;

    private RelativeLayout about_agreement_yingshi;

    private RelativeLayout about_agreement_ertong;

    private RelativeLayout about_agreement_zaiyao;

    private RelativeLayout about_agreement_grqd;

    private RelativeLayout about_agreement_sdkqd;

    private RelativeLayout about_agreement_qxqd;

    private ViewOnClickListener mViewOnClickListener = new ViewOnClickListener() {
        @Override
        public void avertRepeatOnClick(View v) {
            int id = v.getId();
            if (id == R.id.tv_share) {
                ShareQRcodeDialog shareDialog = new ShareQRcodeDialog(AboutActivity.this);
                shareDialog.show();
            } else if (id == R.id.about_agreement_shiyong) {
                //习习向上使用协议
                MeJumpManager.jumpAgreementActivity(R.string.go_back, AboutActivity.this, getString(R.string.agreement_use_url), getString(R.string.agreement_private), AgreementActivity.LOGIN_ACTION);
            } else if (id == R.id.about_agreement_yingshi) {
                //习习向上隐私政策
                MeJumpManager.jumpAgreementActivity(R.string.go_back, AboutActivity.this, getString(R.string.agreement_secret_url), getString(R.string.agreement_secret), AgreementActivity.LOGIN_ACTION);
            } else if (id == R.id.about_agreement_ertong) {
                //儿童隐私保护政策
                MeJumpManager.jumpAgreementActivity(R.string.go_back, AboutActivity.this, getString(R.string.agreement_child_url), getString(R.string.agreement_child), AgreementActivity.LOGIN_ACTION);
            } else if (id == R.id.about_agreement_zaiyao) {
                //习习向上隐私政策摘要
                MeJumpManager.jumpAgreementActivity(R.string.go_back, AboutActivity.this, getString(R.string.agreement_abstract_url), getString(R.string.agreement_abstract), AgreementActivity.LOGIN_ACTION);
            } else if (id == R.id.about_agreement_grqd) {
                //习习向上个人信息收集清单
                MeJumpManager.jumpAgreementActivity(R.string.go_back, AboutActivity.this, getString(R.string.agreement_collect_url), getString(R.string.agreement_collect_list), AgreementActivity.LOGIN_ACTION);
            } else if (id == R.id.about_agreement_sdkqd) {
                //习习向上第三方共享与SDK清单
                MeJumpManager.jumpAgreementActivity(R.string.go_back, AboutActivity.this, getString(R.string.agreement_sdk_list_url), getString(R.string.agreement_sdk_list), AgreementActivity.LOGIN_ACTION);
            } else if (id == R.id.about_agreement_qxqd) {
                //习习向上设备权限清单
                MeJumpManager.jumpAgreementActivity(R.string.go_back, AboutActivity.this, getString(R.string.agreement_device_perm_url), getString(R.string.agreement_device_perm_list), AgreementActivity.LOGIN_ACTION);
            }
        }
    };

    @Override
    protected int setView() {
        return R.layout.activity_about;
    }

    @Override
    protected void findViews() {
        mTvShare = findViewById(R.id.tv_share);
        mIvAppicon = findViewById(R.id.iv_app_icon);
        about_agreement_shiyong = findViewById(R.id.about_agreement_shiyong);
        about_agreement_yingshi = findViewById(R.id.about_agreement_yingshi);
        about_agreement_ertong = findViewById(R.id.about_agreement_ertong);
        about_agreement_zaiyao = findViewById(R.id.about_agreement_zaiyao);
        about_agreement_grqd = findViewById(R.id.about_agreement_grqd);
        about_agreement_sdkqd = findViewById(R.id.about_agreement_sdkqd);
        about_agreement_qxqd = findViewById(R.id.about_agreement_qxqd);

    }

    @Override
    protected void initEvent() {
        about_agreement_shiyong.setOnClickListener(mViewOnClickListener);
        about_agreement_yingshi.setOnClickListener(mViewOnClickListener);
        about_agreement_ertong.setOnClickListener(mViewOnClickListener);
        about_agreement_zaiyao.setOnClickListener(mViewOnClickListener);
        about_agreement_grqd.setOnClickListener(mViewOnClickListener);
        about_agreement_sdkqd.setOnClickListener(mViewOnClickListener);
        about_agreement_qxqd.setOnClickListener(mViewOnClickListener);
        mTvShare.setOnClickListener(mViewOnClickListener);
    }

    @Override
    protected void init() {
        setValideSource(false);
        setTitleText(R.string.about_app);
    }

    @Override
    protected void loadData() {

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == Constants.REQUEST_QQ_SHARE || requestCode == Constants.REQUEST_QZONE_SHARE) {
            QQShareHelper.getInstance().onActivityResultData(requestCode, resultCode, data);
        }
        super.onActivityResult(requestCode, resultCode, data);
    }

}
